package com.lianniu.mgr.teaInfo.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.lianniu.mgr.base.BaseResult;
import com.lianniu.mgr.buyerManage.vo.BuyerConditionVo;
import com.lianniu.mgr.pagination.PaginationInfo;
import com.lianniu.mgr.teaAddr.dao.TeaUserAddrDao;
import com.lianniu.mgr.teaAddr.model.TeaUserAddr;
import com.lianniu.mgr.teaInfo.dao.TeaFrontusersDao;
import com.lianniu.mgr.teaInfo.model.TeaFrontusers;
import com.lianniu.mgr.teaInfo.service.ITeaInfoService;



@Service
@Transactional
public class TeaInfoServiceImpl implements ITeaInfoService {
	
	private final static Logger logger = Logger.getLogger(TeaInfoServiceImpl.class);
	
	@Autowired
	private TeaFrontusersDao teaFrontusersDao;
	@Autowired
	private TeaUserAddrDao teaUserAddrDao;

	@Override
	public BaseResult getTeaInfo(String userId) {
		logger.info("TeaPayServiceImpl balancePay start");
		TeaFrontusers frontusers = teaFrontusersDao.selectByPrimaryKey(Long.valueOf(userId));
		TeaUserAddr teaUserAddr = teaUserAddrDao.selectDefaultAddr(frontusers.getUsersid().toString());
		frontusers.setTeaUserAddr(teaUserAddr);
		return BaseResult.success(frontusers);
	}
	
	@Override
	public TeaFrontusers getTeaInfoByUserId(String userId) {
		logger.info("TeaPayServiceImpl balancePay start");
		TeaFrontusers frontusers = teaFrontusersDao.selectByPrimaryKey(Long.valueOf(userId));
		return frontusers;
	}

	@Override
	public BaseResult selectAllUser(TeaFrontusers teaFrontusers, PaginationInfo paginationInfo) {
		// TODO Auto-generated method stub
		teaFrontusers.setPaginationInfo(paginationInfo);
		List<TeaFrontusers> selectAllUser = teaFrontusersDao.selectAllUserForPage(teaFrontusers);
		Map<String, Object> retmap = new HashMap<String, Object>();
	    retmap.put("total", paginationInfo.getTotalRecord());
	    retmap.put("curPage", paginationInfo.getCurPage());
	    retmap.put("rows", selectAllUser);
		return BaseResult.success(retmap);
	}
}
